package org.dingyom.gift.properties;

import lombok.Data;
import org.dingyom.gift.constants.TypeConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 根据登陆信息的type来判断是用户还是员工
 * 返回的相应的clientId 和 clientSecret
 */
@Configuration
@ConfigurationProperties(prefix = "oauth2.client")
@Data
public class Oauth2ClientDetailsProperties {
    private Oauth2ClientDetails website;
    private Oauth2ClientDetails system;

    public Oauth2ClientDetails getOauth2ClientDetails(Integer type){
        switch (type){
            case TypeConstants
                    .TYPE_WEBSITE_USER:
                return website;
            case TypeConstants
                    .TYPE_SYSTEM_EMPLOYEE:
                return system;
        }
        return null;
    }
}
